package com.tedu.bill.demo1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.function.Consumer;

/**
 * Author：毕龙
 * Date: 2024/5/17 14:10
 */
public class TestCollection1 {
    public static void main(String[] args) {
        ArrayList list = new ArrayList(5);
        list.add(123);
        list.add(list.size(),789);
        ArrayList list1 = new ArrayList();
        list1.add("龙龙");
        list1.add("泽豪");
        list.addAll(list1);
        //将集合中的元素打乱
        Collections.shuffle(list);
        //删除集合中的元素
        list.remove(3);
        //遍历集合
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("===========");
        for (Object o : list) {
            System.out.println(o);
        }
        System.out.println("===========");
        list.forEach(new Consumer() {
            @Override
            public void accept(Object o) {
                System.out.println(o);
            }
        });
        System.out.println("===========");
        list.forEach(o-> System.out.println(o));
        System.out.println("===========");
        list.forEach(System.out::println);
    }
}
